package com.why.amallrest.controller;

import com.why.common.utils.PageUtils;
import com.why.common.utils.Result;
import com.why.entity.OrderItemEntity;
import com.why.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 订单项/快照 
 *
 * @author why
 * @email 1585049082@qq.com
 * @date 2021-10-24 20:16:08
 */
@RestController
@RequestMapping("why/orderitem")
public class OrderItemController {
    @Autowired
    private OrderItemService orderItemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("why:orderitem:list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = orderItemService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{itemId}")
  //  @RequiresPermissions("why:orderitem:info")
    public Result info(@PathVariable("itemId") String itemId){
		OrderItemEntity orderItem = orderItemService.getById(itemId);

        return Result.ok().put("orderItem", orderItem);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   /// @RequiresPermissions("why:orderitem:save")
    public Result save(@RequestBody OrderItemEntity orderItem){
		orderItemService.save(orderItem);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("why:orderitem:update")
    public Result update(@RequestBody OrderItemEntity orderItem){
		orderItemService.updateById(orderItem);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("why:orderitem:delete")
    public Result delete(@RequestBody String[] itemIds){
		orderItemService.removeByIds(Arrays.asList(itemIds));

        return Result.ok();
    }

}
